import { loadConnectionConfig } from './src/ConfigLoader';
import WebSocketServer from './src/adapter/WebSocketServer';
import WebSocketClient from './src/adapter/WebSocketClient';
import Bot from './src/MessageHandler';

// 1. 加载配置
const config = loadConnectionConfig();
const bot = new Bot();

console.log('=== 应用启动 ===');
console.log('配置加载成功:', JSON.stringify(config, null, 2));

// 2. 启动WebSocket服务端
if (config.ws.server.enable) {
  const server = new WebSocketServer(config, bot);
  server.start();
}

// 3. 连接WebSocket客户端
if (config.ws.client.enable) {
  const client = new WebSocketClient(config, bot);
  client.connect();
}